package com.wanxi.step07test.controller;


import com.wanxi.step07test.dto.ResultDTO;
import com.wanxi.step07test.model.BusinessLineModel;
import com.wanxi.step07test.service.impl.BusinessLineServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@CrossOrigin
public class BusinessLineController {

    @Autowired
    private BusinessLineServiceImpl businessLineService;



    @PreAuthorize("hasAuthority('businessLine:findAll')")
    @RequestMapping("/back/businessLine/findAll")
    @ResponseBody
    public ResultDTO findAll(BusinessLineModel businessLine) {

        ResultDTO resultDTO = businessLineService.findAll(businessLine);
        return resultDTO;
    }

    @PreAuthorize("hasAuthority('businessLine:add')")
    @RequestMapping("/back/businessLine/add")
    @ResponseBody
    public ResultDTO add(BusinessLineModel businessLine) {

        ResultDTO resultDTO = businessLineService.add(businessLine);
        return resultDTO;
    }

    @PreAuthorize("hasAuthority('businessLine:delete')")
    @RequestMapping("/back/businessLine/delete")
    @ResponseBody
    public ResultDTO delete(BusinessLineModel businessLine) {

        ResultDTO resultDTO = businessLineService.delete(businessLine);
        return resultDTO;
    }

    @PreAuthorize("hasAuthority('businessLine:findById')")
    @RequestMapping("/back/businessLine/findById")
    @ResponseBody
    public ResultDTO findById(BusinessLineModel businessLine) {

        ResultDTO resultDTO = businessLineService.findById(businessLine);
        return resultDTO;
    }


    @PreAuthorize("hasAuthority('businessLine:update')")
    @RequestMapping("/back/businessLine/update")
    @ResponseBody
    public ResultDTO update(BusinessLineModel businessLine) {

        ResultDTO resultDTO = businessLineService.update(businessLine);
        return resultDTO;
    }


}
